package com.laobiao.file_netty_lib.netty;

import java.util.List;

import com.laobiao.file_netty_lib.packet.PacketUtil;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

/**
 * 对象编码器
 * @author 38079
 *
 */
public class BytesToPacketDecoder extends ByteToMessageDecoder{

	@Override
	protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
		byte[] data=new byte[1024];
		in.readBytes(data);
		out.add(PacketUtil.buildPacket(data));
	}

}
